/*
 * @Author: riaosihan
 * @Date: 2021-04-10 18:25:35
 * @Last Modified by: xiaosihan
 * @Last Modified time: 2021-06-06 20:32:28
 */

import * as THREE from "three";
import Transition from "./Transition";

// 待缓动效果的3d顶点
export default class TransitionColor {

    constructor(color: string) {
        this.set(color);
    }

    _transition = new Transition();

    _color = new THREE.Color();

    set(color: string) {
        this._color.set(color);
        const { r, g, b } = this._color;
        this._transition.set({ r, g, b });
        return this;
    }

    get(key: string) {
        return this._transition.get(key);
    }

    getJson() {
        return this._transition.getJson();
    }

    setDuration(duration: number = 500) {
        this._transition.setDuration(duration);
        return this;
    }

    setBezier(bezier: [number, number, number, number] = [0.8, 0, 0.2, 1]) {
        this._transition.setBezier(bezier);
        return this;
    }

    // // 设置起始位置
    // setStart({ r, g, b }: { [key: string]: number }) {
    //     this._transition.setStart({ r, g, b });
    //     return this;
    // }

    // // 设置结束位置
    // setEnd({ r, g, b }: { [key: string]: number }) {
    //     this._transition.setEnd({ r, g, b });
    //     return this;
    // }

    // reset({ r, g, b }: { [key: string]: number }) {
    //     this._transition.setStart({ r, g, b });
    //     return this;
    // }

    isDone(): boolean {
        return this._transition.isDone();
    }


}